<?php
class Permissions extends Mymodel{
	var $permission_codes=array('access'=>1,'add'=>2,'edit'=>3);
	var $permissions=array(1=>'access',2=>'add',3=>'edit');

	function __construct()
	{
		
	//	parent::__construct();
	 parent::Mymodel();
	}
	
	
    // get all permissions, or permissions from a group for the purposes of listing them in a form
    function get_permissions()
    {
        return $this->permissions;
    }    
    function get_pages_permissions($pag_ID=NULL,$groupID=NULL){
    	// where
        if ($pag_ID)
        {
            $this->db->where('pag_ID', $pag_ID);
        }    
          if ($pag_ID)
        {
            $this->db->where('groupID', $groupID);
        }    
    	$pagePermission=array();
        $query = $this->db->get('permission_map');
        //$this->db->last_query();
    	  if ($query->num_rows())
        {    
        	
            foreach($query->result_array() as $row){
            	$pagePermission[$row['groupID']][$row['pageID']][$row['permissionID']]=1;
            }
        }
      #print_r($pagePermission);
     return $pagePermission;    	
    }

}
   
   